package spring.mvc.dao.impl;


import java.util.List;

import spring.mvc.dao.BoardDao;
import spring.mvc.domain.Board;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class BoardDaoimpl extends SqlSessionDaoSupport implements BoardDao{
	
	@Override
	public Integer write(Board board) throws Exception
	{	
		Integer seq = getSqlSession().selectOne("board.seq");
		board.setSeq(seq);
		getSqlSession().insert("board.write", board);
		return seq;
	}
	
	@Override
	public Board view(String seq) throws Exception
	{
		return (Board) getSqlSession().selectOne("board.view", seq);
				
	}
	
	@Override
	public List <Board> list() throws Exception
	{
		List<Board> list = getSqlSession().selectList("board.list");
		return list;
	}
	
	@Override
	public void update(Board board) throws Exception
	{
		getSqlSession().update("board.update", board);
	}
	
	@Override
	public void delete(String seq) throws Exception
	{
		getSqlSession().delete("board.delete", seq);
	}
	
	@Override
	public Integer addReply(Board board) throws Exception
	{
		
		Integer seq = getSqlSession().selectOne("board.seq");
		board.setSeq(seq);
		getSqlSession().insert("board.addReply", board);
		return seq;
	}

}
